<template>
	<view>
		<fa-navbar :title="$t('activity.join')" :border-bottom="false"></fa-navbar>
		<!-- 图片 -->
		<view class="img">
			<image :src="activity.images" mode=""></image>
		</view>

		<view class="middle">
			<view class="middleTop">
				{{start}}
			</view>

			<view class="middleTitle">
				{{activity.title}}
			</view>
			<view class="walk">
				<view class="Dli">
					{{bet}}
					<br>
					{{$t('activity.bet')}}
				</view>
				<view class="Dli">
					{{activity.total_number}}
					<br>
					{{$t('activity.players')}}
				</view>
				<view class="Dli">
					R${{activity.prize_pool}}
					<br>
					{{$t('activity.pot')}}
				</view>
			</view>
			<view class="date">
				{{activity.start_date}} - {{activity.end_date}} · {{activity.weeks}} {{$t('activity.weeks')}}
			</view>

			<view class="joinBtn" :style="[{backgroundColor:theme.bgColor}]" v-if="activity.status=='started' || activity.status=='unstarted'"
				@click="createOrder">
				{{$t('activity.join')}}
			</view>
			<view class="joinBtn" style="backgroundColor:#ff9900" v-else>
				{{$t('activity.join.end')}}
			</view>
			<view class="text">
				{{activity.content}}
			</view>

		</view>

		<view class="button">
			<view class="left">
				<view class="Ltop" :style="[{backgroundColor:theme.bgColor}]">
					1
				</view>
				<view class="Ltop2">
					{{$t('activity.join.bet')}}
				</view>
				<view class="Ltop3">
					{{$t('activity.join.bet.desc')}}
				</view>
			</view>
			<view class="middle">
				<view class="Ltop" :style="[{backgroundColor:theme.bgColor}]">
					2
				</view>
				<view class="Ltop2">
					{{$t('activity.join.move')}}
				</view>
				<view class="Ltop3">
					{{$t('activity.join.move.desc')}}
				</view>
			</view>
			<view class="right">
				<view class="Ltop" :style="[{backgroundColor:theme.bgColor}]">
					3
				</view>
				<view class="Ltop2">
					{{$t('activity.join.win')}}
				</view>
				<view class="Ltop3">
					{{$t('activity.join.win.desc')}}
				</view>
			</view>
		</view>
		<u-popup border-radius="10" v-model="show" mode="bottom" :mask="true" :closeable="true"
			close-icon-pos="top-right">
			<view class="money-content">
				<view class="u-text-center u-p-10">Selecione o valor da aposta</view>
				<view class="u-text-center u-p-10"><u-radio-group v-model="money" placement="row">
						<u-radio iconSize="16px" size="16px" labelSize="16px" :customStyle="{marginRight: '18px'}"
							v-for="(item, index) in money_list" :key="index" :label="item.name"
							:name="item.name">{{item.name}}
						</u-radio>
					</u-radio-group></view>
				<view class="confrim-btn u-p-t-20">
					<u-button size="medium" type="primary" hover-class="none"
						:custom-style="{ width: '80vw', backgroundColor: theme.bgColor, color: theme.color }"
						shape="circle" @click="show = false">
						Tem certeza
					</u-button>
				</view>
			</view>
		</u-popup>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				activity: {},
				money_list: [],
				money: '100',
				bet: '',
				start: ''
			};
		},
		onLoad(options) {
			let id = options.id
			this.getActivityDetail(id)
		},
		methods: {
			popup_money() {
				this.show = true;
			},
			getActivityDetail(id) {
				this.$api.activityDetail({
					id: id
				}).then(res => {
					if (res.code == 1) {
						this.money_list = res.data.money_list
						this.activity = res.data;
						this.activity.prize_pool = this.activity.prize_pool.toLocaleString("pt-BR")
						this.bet = res.data.money_json.join('-')
						let status = res.data.status
						let days = res.data.days

						if (status == 'started') {
							if (days > 1 ) {
								this.start = this.$t('activity.join.start.week')
							} else if (days == 1) {
								this.start = this.$t('activity.join.start.today')
							}
						}else if(status == 'unstarted'){
							this.start = this.$t('activity.join.start.days', {
								days: days
							})
						}
					}

				});
			},
			createOrder(){
				//todo create order
				this.goPage('/pages/activity/order?id=' + activity.id)
			}

		}

	}
</script>

<style lang="scss" scoped>
	.money-content {
		padding: 24rpx;
		text-align: center;
	}

	.img {
		width: 100%;
		height: 180px;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.middle {
		width: 100%;
		margin: 0 auto;

		.middleTop {
			display: flex;
			justify-content: center;
			width: 100%;
			color: #1F9F60;
			margin: 20px auto;
			font-size: 15px;
			font-weight: bold;
		}

		.middleTitle {
			display: flex;
			justify-content: center;
			width: 100%;
			color: #000000;
			margin: 2px auto;
			font-weight: bold;
			font-size: 22px;
		}

		.walk {
			display: flex;
			justify-content: center;

			.Dli {
				padding: 0 15px;
				text-align: center;
			}
		}

		.date {
			display: flex;
			justify-content: center;
			width: 100%;
			color: #000000;
			margin: 10px auto;
			font-size: 14px;
		}

		.joinBtn {
			width: 300px;
			height: 40px;
			background-color: #1F9F60;
			display: flex;
			align-items: center;
			justify-content: center;
			color: #fff;
			border-radius: 26px;
			margin: 0 auto;
			margin-top: 30px;
			cursor: pointer;
		}

		.text {

			color: #000000;
			font-size: 14px;
			margin: 20px auto;
			text-align: center;


		}



	}

	.button {
		// width: 100%;
		margin: 40px 5%;
		display: flex;

		// padding: 0 5%;
		.left,
		.middle,
		.right {
			width: 30%;
			text-align: center;

			.Ltop {
				width: 40px;
				height: 40px;

				background-color: #1F9F60;
				border-radius: 40px;
				display: flex;
				justify-content: center;
				align-items: center;
				color: #fff;
				margin: 6px auto;

			}

			.Ltop2 {
				font-size: 14px;
				margin: 4px auto;
				font-weight: bold;
			}

			.Ltop3 {
				font-size: 12px;
			}
		}

	}
</style>